﻿// --------------------------------
// <copyright file="MethodParameterTest.cs" company="TRONSoft">
//     Copyright (c) TRONSoft.
// </copyright>
// <license>
//   This source code is subject to terms and conditions of the Microsoft
//   Public License. A copy of the license can be found in the License.html
//   file at the root of this distribution. If you cannot locate the
//   Microsoft Public License, please send an email to dlr@microsoft.com.
//   By using this source code in any fashion, you are agreeing to be bound 
//   by the terms of the Microsoft Public License. You must not remove this
//   notice, or any other, from this software.
// </license>
// <author>Tron</author>
// ---------------------------------

using System;
using System.CodeDom;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tronsoft.Actucal.CalculationEngineCreator.Test
{       
    /// <summary>
    ///This is a test class for MethodParameterTest and is intended
    ///to contain all MethodParameterTest Unit Tests
    ///</summary>
    [TestClass()]
    public class MethodParameterTest
    {
        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        /// <summary>
        ///A test for Type
        ///</summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Type_May_Not_Be_Null_Test()
        {
            string name = "p1";
            Type type = null; 
            MethodParameter target = new MethodParameter(name, type); 
        }

        /// <summary>
        ///A test for Type
        ///</summary>
        [TestMethod()]
        public void Type_Test()
        {
            string name = "p1";
            Type type = typeof(string);
            MethodParameter target = new MethodParameter(name, type); 
            Assert.AreEqual(typeof(string), target.Type);
        }

        /// <summary>
        ///A test for Name
        ///</summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Name_May_Not_Be_Null_Test()
        {
            string name = null;
            Type type = typeof (int);
            MethodParameter target = new MethodParameter(name, type); 
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Name_May_Not_Be_Empty_Test()
        {
            string name = "";
            Type type = typeof(int);
            MethodParameter target = new MethodParameter(name, type);
        }

        /// <summary>
        ///A test for Name
        ///</summary>
        [TestMethod()]
        public void Name_Test()
        {
            string name = "p1";
            Type type = typeof (int);
            MethodParameter target = new MethodParameter(name, type); 
            Assert.AreEqual("p1", target.Name);
        }

        /// <summary>
        ///A test for Direction
        ///</summary>
        [TestMethod()]
        public void Direction_Test()
        {
            string name = "p1";
            Type type = typeof (int);
            MethodParameter target = new MethodParameter(name, type); 
            Assert.AreEqual(FieldDirection.In, target.Direction);
        }

        /// <summary>
        ///A test for Direction
        ///</summary>
        [TestMethod()]
        public void Direction_Should_Be_In_Test()
        {
            string name = "p1";
            Type type = typeof(int);
            MethodParameter target = new MethodParameter(name, FieldDirection.In, type);
            Assert.AreEqual(FieldDirection.In, target.Direction);
        }

        /// <summary>
        ///A test for Direction
        ///</summary>
        [TestMethod()]
        public void Direction_Should_Be_Out_Test()
        {
            string name = "p1";
            Type type = typeof(int);
            MethodParameter target = new MethodParameter(name, FieldDirection.Out, type);
            Assert.AreEqual(FieldDirection.Out, target.Direction);
        }

        /// <summary>
        ///A test for Direction
        ///</summary>
        [TestMethod()]
        public void Direction_Should_Be_Ref_Test()
        {
            string name = "p1";
            Type type = typeof(int);
            MethodParameter target = new MethodParameter(name, FieldDirection.Ref, type);
            Assert.AreEqual(FieldDirection.Ref, target.Direction);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void MethodParameter_A_Name_Cannot_Contain_Spaces()
        {
            MethodParameter target = new MethodParameter("g b", FieldDirection.Ref, typeof(string));
        }
    }
}
